<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--Converted with LaTeX2HTML 96.1 (Feb 5, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds -->


<title>Factorial Frequencies</title>
<meta name="description" content="Factorial Frequencies">
<meta name="keywords" content="htmlatex">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<link rel="STYLESHEET" href="acm-00324_archivos/htmlatex.css">
</head><body bgcolor="#ffffff" lang="EN">
 <h1><br clear="all"><center><table bgcolor="#0060f0"><tbody><tr><td><b><font color="#c0ffff" size="5">&nbsp;<a name="SECTION0001000000000000000000">Factorial Frequencies</a></font>&nbsp;</b></td></tr></tbody></table></center></h1>
<p> In an attempt to bolster her sagging palm-reading business,
Madam Phoenix has decided to offer several numerological treats to
her customers. She has been able to convince them that the
frequency of occurrence of the digits in the decimal representation of
factorials bear witness to their futures. Unlike palm-reading, however,
she can't just conjure up these frequencies, so she has
employed you to determine these values.
</p><p>
</p><p>
     Recall that the definition of <i>n</i>! (that is, <i>n</i> factorial) is just  <img alt="tex2html_wrap_inline28" src="acm-00324_archivos/324img1.gif" align="middle" height="24" width="140"> . As she expects to use either the day of the week, the day of
the month, or  the  day  of  the  year  as  the  value  of  <i>n</i>,   you   must
be  able  to determine the number of  occurrences  of  each  decimal  digit
in  numbers  as  large  as  366  factorial  (366!), which has 781 digits.
</p><p>
</p><h2><font color="#0070e8"><a name="SECTION0001001000000000000000">Input and Output</a></font></h2>
<p>
     The input data for the program is  simply  a  list  of  integers   for
which   the   digit  counts  are  desired.  All  of these input values will
be less than or equal to 366 and greater  than  0,  except  for  the   last
integer,   which will be zero.  Don't bother to process  this  zero  value;
just  stop  your  program  at  that  point.  The  output  format  isn't  too
critical,   but   you   should  make  your  program  produce  results  that
look  similar  to  those shown below.
</p><p>
</p><p>
     Madam Phoenix will be forever (or longer)  in  your  debt;  she  might
even  give  you  a  trip  if  you  do  your  job well!
</p><p>
</p><h2><font color="#0070e8"><a name="SECTION0001002000000000000000">Sample Input</a></font></h2>
<p>
</p><pre>3
8
100
0</pre>
<p>
</p><h2><font color="#0070e8"><a name="SECTION0001003000000000000000">Sample Output</a></font></h2>
<p>
</p><pre>3! --
   (0)    0    (1)    0    (2)    0    (3)    0    (4)    0
   (5)    0    (6)    1    (7)    0    (8)    0    (9)    0
8! --
   (0)    2    (1)    0    (2)    1    (3)    1    (4)    1
   (5)    0    (6)    0    (7)    0    (8)    0    (9)    0
100! --
   (0)   30    (1)   15    (2)   19    (3)   10    (4)   10
   (5)   14    (6)   19    (7)    7    (8)   14    (9)   20</pre>
<p>
</p></body></html>